#     Xepec.ru - социальная сеть
#     Copyright (C) 2008  Fedorchenko Alexander <admin@xepec.ru>
#
#     This program is free software: you can redistribute it and/or modify
#     it under the terms of the GNU Affero General Public License as
#     published by the Free Software Foundation, either version 3 of the
#     License, or (at your option) any later version.
#
#     This program is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU Affero General Public License for more details.
#
#     You should have received a copy of the GNU Affero General Public License
#     along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#     Autor: Fedorchenko Alexander
#     Mail: <admin@xepec.ru>
#     Date: 06/02/2010
#

#require "config.pl";
require "core.pl";

use CGI::Cookie;
%cookies = fetch CGI::Cookie;
$auth_email=$cookies{'xepec_nic'}->value;#$_POST['mail'];
$auth_pass=$cookies{'xepec_pass'}->value;#$_POST['pass'];$auth_pass_md5=md5($auth_pass);
#$auth_email="sos";

#$uname_auth=do_auth($auth_email,$auth_pass_md5);

#$as = uname_get($uname_auth);
# if ($uname_auth == FALSE)
# {
# 	header("Location: /?error=01");
# }
# else
# {
# #	echo " <script type=\"text/javascript\">
# #	var pass = '".$_POST['pass']."';
# #	var jid = jid = '".$as['nic']."' + '@' + 'jabber.xepec.ru' + '/'+ 'Home-' + Math.round(Math.random()*100000);
# #	//window.open('index1.php','sdf','width=180,height=390,resizable=yes');
# #	top.location.href='index1.php';
# #	</script>";
# 	header("Location: /username.php?uname=$uname_auth");
# 	#header("Location: http://ya.ru ");
# }
$uname_auth=do_auth($auth_email,$auth_pass);
#echo $uname_auth;
if ($uname_auth == FALSE)
{
	print"Location: /error.php?error=404\n\n";
}
else
{
	print"Location: /username/index.pl?uname=".$uname_auth."\n\n";
}
